package com.dxg.msns.common.pojo;

import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.Table;
import java.io.Serializable;
import java.util.Date;

/**
 * 用户歌曲历史记录实体类
 * 对应数据库表：user_history
 * 
 * @author system
 */
@Table(name = "user_history")
public class UserHistory implements Serializable {
    private static final long serialVersionUID = 1L;

    /**
     * 主键ID
     */
    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    private Long id;

    /**
     * 用户ID
     */
    private String userId;

    /**
     * 音乐ID
     */
    private String musicId;

    /**
     * 记录时间
     */
    private Date createTime;

    // 构造方法
    public UserHistory() {
    }

    public UserHistory(String userId, String musicId) {
        this.userId = userId;
        this.musicId = musicId;
        this.createTime = new Date();
    }

    public UserHistory(String userId, String musicId, Date createTime) {
        this.userId = userId;
        this.musicId = musicId;
        this.createTime = createTime;
    }

    // Getter 和 Setter 方法
    public Long getId() {
        return id;
    }

    public void setId(Long id) {
        this.id = id;
    }

    public String getUserId() {
        return userId;
    }

    public void setUserId(String userId) {
        this.userId = userId;
    }

    public String getMusicId() {
        return musicId;
    }

    public void setMusicId(String musicId) {
        this.musicId = musicId;
    }

    public Date getCreateTime() {
        return createTime;
    }

    public void setCreateTime(Date createTime) {
        this.createTime = createTime;
    }

    @Override
    public String toString() {
        return "UserHistory{" +
                "id=" + id +
                ", userId='" + userId + '\'' +
                ", musicId='" + musicId + '\'' +
                ", createTime=" + createTime +
                '}';
    }

    @Override
    public boolean equals(Object o) {
        if (this == o)
            return true;
        if (o == null || getClass() != o.getClass())
            return false;

        UserHistory that = (UserHistory) o;

        if (!userId.equals(that.userId))
            return false;
        return musicId.equals(that.musicId);
    }

    @Override
    public int hashCode() {
        int result = userId.hashCode();
        result = 31 * result + musicId.hashCode();
        return result;
    }
}